<script setup lang="ts">
import { ref } from 'vue'

defineProps<{ msg: string }>()

const list:any = ref([])
const urls:any = ref([])
const keyword = ref('')
const add = () => {
  window.ipcRenderer.send('add-task',keyword.value)
}

const stop = () => {
  window.ipcRenderer.send('stop-task')
}

window.ipcRenderer.on('urls', (event, keyword='') => {
  console.log(keyword);
  // count.value = keyword
  urls.value.push(...JSON.parse(keyword))
})
window.ipcRenderer.on('add-task',(event, keyword='') => {
  // console.log(keyword);
  // count.value = keyword
  list.value.push(...JSON.parse(keyword))
})
</script>

<template>
  <!-- <h1>{{ msg }}</h1> -->

  <div class="card">
    <input v-model="keyword" />
    <button type="button" @click="add">start</button>
    <button type="button" @click="stop">stop</button>

    <div>
      {{ urls }}
    </div>
    <div>
      <template v-for="item in list">
        <div>
          <h2>{{ item.title }}</h2>
          <div v-html="item.description">
          </div>
          <div>
            {{ item.url }}
          </div>
          <div>
            {{ item.resource }}
          </div>
        </div>
      </template>
    </div>
    <p>
      <!-- <div v-richText="count"></div> -->
      <!-- {{ list }} -->
      <!-- <code>components/HelloWorld.vue</code> to test HMR -->
    </p>
  </div>

  <p>
    Check out
    <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
      >create-vue</a
    >, the official Vue + Vite starter
  </p>
  <p>
    Install
    <a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
    in your IDE for a better DX
  </p>
  <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
</template>

<style scoped>
.read-the-docs {
  color: #888;
}
</style>
